var approot_modlue =  approot + "/chapter";

var validate_rules = {
			username:{
				required:true,
				minlength:2,
				maxlength:16
			},
			nicheng:{
				required:true,
				minlength:2,
				maxlength:16
			},
			sex:{
				required:true,
			},
			phone:{
				required:true,
				isMobile:true,
			},
			amail:{
				required:true,
				email:true,
			},
			uploadfile:{
				required:false,
			},
		}

	/*
	 * 提交成功之后，执行的方法
	 * 
	 * 
	 * 
	 * 
	 */
		function afterSubmitSuccess(data){
			if(data.indexOf("更新成功！") >=0){
				layer.msg(data,{
					icon:1,
					time:1000
					},function(){
								window.parent.location.reload();//刷新父页面
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);//关闭自身页面	
							
							});
			}else{
				layer.msg(data,{
					icon:2,
					time:1000
					},function(){

				});
				}
		}

$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-member-add").validate({
		rules:validate_rules,
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: "POST",
				dataType:"text",
				url:approot_modlue + "/save.do",
                success:function(data){
                	afterSubmitSuccess(data);
                     }

				});          
		  }
	});
});